/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.delivery.entities;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;

/**
 *
 * @author Martin Huněk
 */
@Entity
public class Courier extends User implements Serializable {
    
   @OneToMany(fetch= FetchType.EAGER, mappedBy = "courier")
    private Set<Delivery> deliveries = new HashSet<Delivery>();

    public Set<Delivery> getDeliveries() {
        return deliveries;
    }

    public void setDeliveries(Set<Delivery> deliveries) {
        this.deliveries = deliveries;
    }

    @Override
    public String toString() {
        return "Courier{" + "id=" + getId() + ", login=" + getLogin() + ", contact=" + getContact() + ", deliveries=" + deliveries + '}';
    }
    
    
    public void addDelivery(Delivery delivery) {
        deliveries.add(delivery);
    }
    
    public void removeDelivery(Delivery delivery) {
        deliveries.remove(delivery);
    }
    
    
    
}
